﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace GameSchool.Utils
{
    public class FileUtil
    {
        /// <summary>
        /// Vistar skrá úr byte stream niður í skrá á disk
        /// </summary>
        /// <param name="destFilePath"></param>
        /// <param name="binaryFileToSave"></param>
        public static void SaveBinaryFileToDisk(string destFilePath, byte[] binaryFileToSave)
        {
            try
            {
                // Búa til nýtt streymi, skrifað er yfir skrá ef hún er til nú þegar
                using (var fs = new FileStream(destFilePath, FileMode.Create))
                {
                    // Vista skrá
                    fs.Write(binaryFileToSave, 0, binaryFileToSave.Length);
                    // Ganga frá
                    fs.Close();
                }
            }
            catch (Exception e)
            {
                throw new Exception("SaveBinaryFileToDisk(): " + e.Message);
            }
        }

    }
}